package com.itqf.controller;

import cn.dsna.util.images.ValidateCode;

import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/code")
public class CodeController extends BaseServlet{
    //生成验证码
    public void createCode(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        ValidateCode validateCode = new ValidateCode(100,35,5,20);
        String code = validateCode.getCode();
        req.getSession().setAttribute("code",code);

        ServletOutputStream outputStream = resp.getOutputStream();
        validateCode.write(outputStream);
    }
}
